package com.typy.www.tpay.ui.acitivity;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.typy.www.tpay.R;
import com.typy.www.tpay.base.BaseBackActivity;
import com.typy.www.tpay.util.GlideUtils;
import com.typy.www.tpay.util.listviewanimations.IntentUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/7/29.
 */

public class ImageActivity extends BaseBackActivity {

    @BindView(R.id.img)
    ImageView img;
    private String url;

    public static void show(Context context,String url) {
        Intent intent=new Intent();
        intent.putExtra("url",url);
        IntentUtil.intent2Activity(context,intent, ImageActivity.class);
    }

    @Override
    protected void initView() {
        super.initView();
        ButterKnife.bind(this);
        setTranslucentStatus(true);
        url=getIntent().getStringExtra("url");
//        Glide.with(getActivity()).load(url).placeholder(R.drawable.imgloading).into(img);
        GlideUtils.setImage(getActivity(),url,img);
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
    @Override
    protected int getTitleBarResId() {
        return -1;
    }

    @Override
    protected int getContentResId() {
        return R.layout.imageview;
    }


}
